<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/8/12
 * Time: 5:05 PM
 * To change this template use File | Settings | File Templates.
 */
defined('_JEXEC') or die;

class VastViewDanhhieus extends JViewLegacy
{
    protected $items;
    protected $pagination;
    protected $state;
    protected $canDo;

    /**
     * Display the view
     *
     * @return	void
     */
    public function display($tpl = null)
    {
        $this->items		= $this->get('Items');
        $this->pagination	= $this->get('Pagination');
        $this->state		= $this->get('State');

        JLoader::register('DanhhieusHelper', JPATH_COMPONENT . '/helpers/danhhieu.php');

        $this->canDo        = DanhhieusHelper::getActions();

        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }

        $this->addToolbar();

        parent::display($tpl);
    }

    /**
     * Add the page title and toolbar.
     *
     * @since	1.6
     */
    protected function addToolbar()
    {
        JToolBarHelper::title(JText::_('COM_VAST_MANAGER_DANHHIEUS'), 'head vm_manufacturer_48');
        if ($this->canDo->get('vast.danhmuc.manage')) {
            JToolBarHelper::addNew('danhhieu.add', 'COM_VAST_DANHHIEU_JTOOLBAR_NEW');
        }
        if ($this->canDo->get('vast.danhmuc.manage')) {
            JToolBarHelper::editList('danhhieu.edit', 'COM_VAST_DANHHIEU_JTOOLBAR_EDIT');
        }
        if ($this->canDo->get('vast.danhmuc.manage')) {
            JToolBarHelper::deleteList('', 'danhhieus.delete', 'COM_VAST_DANHHIEU_JTOOLBAR_DELETE');
        }
        if ($this->canDo->get('core.admin')) {
            JToolBarHelper::divider();
            JToolBarHelper::preferences('com_vast', '550', '875', 'COM_VAST_JTOOLBAR_OPTIONS');
        }
    }
}